﻿//-----------------------------------------------------------------------
// <copyright file="CollaboratePublicService.cs" company="Simnova LLC">
//     Copyright (c) Simnova LLC. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace Simnova.Collaborate.ServiceImplementation
{
    using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.Text;
    using System.ServiceModel;
    using System.ServiceModel.Activation;
    using System.ServiceModel.Description;
    using System.Configuration;
    using Simnova.Collaborate.ServiceContract;
    using Simnova.Collaborate.ServiceContract.DataClasses;
    using System.Globalization;
    
    /// <summary>
    /// This is the implementation fo the CollaboratePublicService contract. Allows public REST style access to data.
    /// </summary>
    public class CollaboratePublicService : ServiceContract.ServiceContracts.ICollaboratePublicService
    {
        #region ICollaboratePublicService Members

        /// <summary>
        /// Gets tasks for a particular user
        /// </summary>
        /// <param name="userId">The User ID</param>
        /// <returns>A List of Tasks</returns>
        public Task[] GetMyTasks(string userId)
        {
            return DataProvider.Instance().GetTasksByUser(int.Parse(userId, CultureInfo.InvariantCulture)).ToArray();
        }

        #endregion

        #region ICollaboratePublicService Members

        /// <summary>
        /// Gets a particular user's details given a user id.
        /// </summary>
        /// <param name="userId">The User's Identifier</param>
        /// <returns>User Object</returns>
        public User GetUser(string userId)
        {
            return DataProvider.Instance().GetUserById(int.Parse(userId, CultureInfo.InvariantCulture));
        }

        #endregion
    }
}
